package id.net.iconpln.bb.client.view;

import id.net.iconpln.bb.client.model.BeanModelMasterBb;
import id.net.iconpln.bb.client.model.BeanModelPengendalianBb;
import id.net.iconpln.bb.client.service.BatubaraService;
import id.net.iconpln.bb.client.service.BatubaraServiceAsync;
import id.net.iconpln.bb.client.service.MasterRPCService;
import id.net.iconpln.bb.client.service.MasterRPCServiceAsync;
import id.net.iconpln.bb.client.service.PengendalianRPCService;
import id.net.iconpln.bb.client.service.PengendalianRPCServiceAsync;
import id.net.iconpln.bb.client.service.PerencanaanRPCService;
import id.net.iconpln.bb.client.service.PerencanaanRPCServiceAsync;
import id.net.iconpln.bb.client.util.ClientModule;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.GroupingStore;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.util.IconHelper;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.DateTimePropertyEditor;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.MultiField;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.grid.CellSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridGroupRenderer;
import com.extjs.gxt.ui.client.widget.grid.GroupColumnData;
import com.extjs.gxt.ui.client.widget.grid.GroupingView;
import com.extjs.gxt.ui.client.widget.grid.RowNumberer;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.layout.client.Layout.Alignment;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class PageBbJadwal extends LayoutContainer {
	private final PengendalianRPCServiceAsync service = GWT.create(PengendalianRPCService.class);
	private final MasterRPCServiceAsync masterService = GWT.create(MasterRPCService.class);
	private FormData formData;	
	private FormBinding formBindings;
	private Grid gridPltu,gridRencKirim;
	private ListStore storePltu,storePemasok,storeJnsKontrak;
	private GroupingStore storeRencKirim;
	private Button bSubmit;
	private TextField noPjbb;
	private ComboBox cboPemasok,cboJnsKontrak;
	
	@Override
	  protected void onRender(Element parent, int pos) {
	    super.onRender(parent, pos); 
	    setLayout(new FitLayout());  
	    String mdl = Registry.get("isModule");
	    initStore();
	    
	    DateTimeFormat dt = DateTimeFormat.getFormat("dd/MM/YYYY");
	    formData = new FormData("-20");
	    
	    ContentPanel cp = new ContentPanel();    
	    cp.setHeaderVisible(false);
	    cp.setFrame(true);  
	    cp.setSize(1030, 600);  
	    cp.setLayout(new RowLayout(Orientation.HORIZONTAL));  
	  
//	    
	    gridPltu = createGridPltu();

	    ContentPanel pPltu = new ContentPanel();
	    pPltu.setHeaderVisible(false);
	    pPltu.setLayout(new FitLayout());
	    pPltu.add(gridPltu);
//	    
	    ToolBar tbPltu = new ToolBar();
	    tbPltu.add(new LabelToolItem("Data Pembangkit"));
	    tbPltu.add(new SeparatorToolItem());
	    pPltu.setTopComponent(tbPltu);
//	    
	    getServiceInfo("master_pltu","LISTPENGIRIMAN");
//	    getServiceInfo("master_jnskontrak","JENISKONTRAK");
	    
	    

	    FormPanel pFormKontrak = createForm(); 
	    pFormKontrak.setScrollMode(Scroll.AUTO);
	    formBindings = new FormBinding(pFormKontrak, true);

	    

	    gridRencKirim = createGridRencPengiriman();
	    
	    ContentPanel pDelimeter = new ContentPanel();
	    pDelimeter.setWidth(10);
	    pDelimeter.setHeaderVisible(false);
	    pDelimeter.setLayout(new FitLayout());
	    
	    ToolBar tbKontrak = new ToolBar();
	    tbKontrak.add(new LabelToolItem("Data Renc Pengiriman"));
	    tbKontrak.add(new SeparatorToolItem());

	    
	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);
	    p.setLayout(new RowLayout(Orientation.VERTICAL));	    	    
	    
//	    if (mdl.equals("PENGADAAN")){
//	    	p.add(pPltu, new RowData(.99, .4));
//	    	p.add(pFormKontrak, new RowData(.99, .6));	    	
//	    }else{
	    	p.add(pPltu, new RowData(.99, 1));
//	    }

	    p.setTopComponent(tbPltu);

	    ContentPanel pKirim = new ContentPanel();
	    pKirim.setHeaderVisible(false);
	    pKirim.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKirim.add(gridRencKirim,new RowData(.99, 1));
	    pKirim.setTopComponent(tbKontrak);
	    
	    cp.add(p, new RowData(.4, 1));
//	    cp.add(pDelimeter, new FitData(5));
	    cp.add(pKirim, new RowData(.6, 1));
	    
	    
	    add(cp, new FitData(5)); 
	  }  
	  
	        
	    private void initStore(){
	      	storePltu = new ListStore();	
	      	storeRencKirim = new GroupingStore();
//	      	storePemasok= new ListStore();
//	      	storeJnsKontrak = new ListStore();
	     }

	    private Grid createGridPltu(){
    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

    ColumnConfig column = new ColumnConfig();	    	     
    
    column = new ColumnConfig();  
    column.setId("id_pltu");  
    column.setHidden(true);
    column.setWidth(1);    
    configs.add(column);  


    column = new ColumnConfig();  
    column.setId("nama_pembangkit");  
    column.setHeader("Nama");    
    column.setWidth(200);    
    configs.add(column);  

    column = new ColumnConfig();  
    column.setId("jml_kirim");  
    column.setHeader("Pengiriman");  
    column.setWidth(90);  
    configs.add(column);  	  

//    column = new ColumnConfig();  
//    column.setId("jml_pemasok");  
//    column.setHeader("Pemasok");  
//    column.setWidth(80);  
//    configs.add(column);  	  
//    
//    column = new ColumnConfig();  
//    column.setId("ktrk_spot");  
//    column.setHeader("Spot");  
//    column.setWidth(50);  
//    configs.add(column);  	  
//    
    storePltu.setMonitorChanges(true);
    
    ColumnModel cm = new ColumnModel(configs);  
  
    gridPltu = new Grid(storePltu, cm);
    gridPltu.setLoadMask(true);  
    gridPltu.mask("load Data ...","x-mask-loading");
    gridPltu.getView().setEmptyText("Data Empty");  
    gridPltu.setBorders(false);  
//    grid.setAutoExpandColumn("pemasok");  
    gridPltu.setBorders(true);  
    gridPltu.addListener(Events.CellClick, new Listener<BaseEvent>() {            
        public void handleEvent(BaseEvent ge) {
        	try{        		
        		Registry.register("id_pltu",gridPltu.getSelectionModel().getSelectedItem().get("id_pltu").toString());
        		gridRencKirim.mask("load Data ....","x-mask-loading");
        		getServiceInfo("master_kirim","LISTPENGIRIMANBYPEMASOK");
//        		getServiceInfo("master_pemasok","PEMASOK_BY_PLTU");
        		
        	}catch (Exception e) {
				// TODO: handle exception
        		e.getMessage();
			}
        	
        }
	});

		return gridPltu;
	
	} 
private void getServiceInfo(String ctrl,String kode){
	Map mapParam = new FastMap();
//	if (ctrl.equals("master_pemasok")){
//		mapParam.put("id_pltu",Registry.get("id_pltu"));
//				masterService.getMaster(kode,mapParam,new AsyncCallback<List<Map>>() {
//						public void onFailure(Throwable caught) {
//							GWT.log(caught.getMessage(), null);
//						}
//						public void onSuccess(List<Map> result) {
//					    	storePemasok.removeAll();
//					    	storePemasok.add(ClientModule.setListBaseModelFromListMap(result));
////					    	storePemasok.unmask();
//					}
//				});
//	}else if (ctrl.equals("master_jnskontrak")){ 			
//		masterService.getMaster(kode,mapParam,new AsyncCallback<List<Map>>() {
//			public void onFailure(Throwable caught) {
//				GWT.log(caught.getMessage(), null);
//			}
//			public void onSuccess(List<Map> result) {
//				storeJnsKontrak.removeAll();
//				storeJnsKontrak.add(ClientModule.setListBaseModelFromListMap(result));
////		    	storePemasok.unmask();
//		}
//	});
//	}else 
   if (ctrl.equals("master_pltu")) {
		
	service.getListPengiriman(kode,mapParam,new AsyncCallback<List<Map>>() {
			public void onFailure(Throwable caught) {
				GWT.log(caught.getMessage(), null);
			}
			public void onSuccess(List<Map> result) {
		    	storePltu.removeAll();
		    	storePltu.add(ClientModule.setListBaseModelFromListMap(result));
		    	gridPltu.unmask();
		}
	});
	}else if (ctrl.equals("master_kirim")) {
		mapParam.put("id_pltu",Registry.get("id_pltu"));
		service.getListPengiriman(kode,mapParam,new AsyncCallback<List<Map>>() {
				public void onFailure(Throwable caught) {
					GWT.log(caught.getMessage(), null);
				}
				public void onSuccess(List<Map> result) {
			    	storeRencKirim.removeAll();
			    	storeRencKirim.add(ClientModule.setListBaseModelFromListMap(result));
			    	gridRencKirim.unmask();
			}
		});
	}
}

private Grid createGridRencPengiriman(){
	
	 storeRencKirim.groupBy("pemasok");  
	 List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

	    ColumnConfig column = new ColumnConfig();	    	     
	  
	    column = new ColumnConfig();  
	    column.setId("pemasok");  
	    column.setHeader("Pemasok");  
	    column.setWidth(150);  
	    configs.add(column);  	  

	    column = new ColumnConfig();  
	    column.setId("nama_transport");  
	    column.setHeader("Kapal");  
	    column.setWidth(150);  
	    configs.add(column);  	  
	    
	    
	    column = new ColumnConfig();  
	    column.setId("tgl_ta");  
	    column.setHeader("ETA");  
	    column.setWidth(100);  
	    configs.add(column);  	  

	    column = new ColumnConfig();  
	    column.setId("tgl_td");  
	    column.setHeader("ETD");  
	    column.setWidth(100);  
	    configs.add(column);  	  
	    
	    column = new ColumnConfig();  
	    column.setId("volume");  
	    column.setHeader("Volume");  
	    column.setAlignment(HorizontalAlignment.RIGHT);
	    column.setWidth(150);  
	    configs.add(column);  	  
	    


	    column = new ColumnConfig();  
	    column.setId("status");  
	    column.setHeader("Status");  
	    column.setWidth(100);  
	    configs.add(column);  	  

	    
	    storePltu.setMonitorChanges(true);
	    
	    final ColumnModel cm = new ColumnModel(configs);  
	 
	    GroupingView view = new GroupingView();  
	    view.setShowGroupedColumn(false);  
//	    view.setForceFit(true);  
	    view.setGroupRenderer(new GridGroupRenderer() {  
		@Override
		public String render(GroupColumnData data) {
			// TODO Auto-generated method stub
			  String f = cm.getColumnById(data.field).getHeader();  
		        String l = data.models.size() == 1 ? "Pemasok" : "Pemasok";  
		        return f + ": " + data.group ; //+ " (" + data.models.size() + " " + l + ")";
		}  
	    });
	    
	    gridRencKirim = new Grid(storeRencKirim, cm);
	    gridRencKirim.setView(view);  
//	    gridKontrak.setLoadMask(true);  
//	    gridKontrak.mask("load Data ...","x-mask-loading");
	    gridRencKirim.getView().setEmptyText("Data Empty");  
	    gridRencKirim.setBorders(false);  
//	    grid.setAutoExpandColumn("pemasok");  
	    gridRencKirim.setBorders(true);  
	  

			return gridRencKirim;
	}
private FormPanel createForm() {  
    FormPanel panel = new FormPanel();	    
    panel.setHeaderVisible(false);
    
    FieldSet fieldSet = new FieldSet();  
    fieldSet.setHeading("Entry Kontrak");  
    fieldSet.setCollapsible(false);
    
  
    FormLayout layout = new FormLayout();  
    layout.setLabelWidth(110);  
    fieldSet.setLayout(layout);  

    noPjbb = new TextField<String>();  
    noPjbb.setName("no_pjbb");  
    noPjbb.setFieldLabel("No PJBB");    
    noPjbb.setReadOnly(true);
    fieldSet.add(noPjbb, formData);	
    
		cboPemasok = new ComboBox();  
		//cboJetty.setName("id_unit_jetty");  
		cboPemasok.setFieldLabel("Pemasok");
		cboPemasok.setEmptyText("Select Pemasok...");  
		cboPemasok.setDisplayField("pemasok");  
		cboPemasok.setWidth(150);  
		cboPemasok.setStore(storePemasok);  
		cboPemasok.setTypeAhead(true);  
		cboPemasok.setTriggerAction(TriggerAction.ALL);
//		cboPemasok.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
//			@Override
//			public void selectionChanged(SelectionChangedEvent<ModelData> se) {
//				// TODO Auto-generated method stub
//				aktivitasDermaga("master","UNIT","", "");    		
//			}
//		});
    
	fieldSet.add(cboPemasok, formData);	
	
    
	cboJnsKontrak = new ComboBox();  
	//cboJetty.setName("id_unit_jetty");  
	cboJnsKontrak.setFieldLabel("Jns Kontrak");
	cboJnsKontrak.setEmptyText("Select Jns Kontrak...");  
	cboJnsKontrak.setDisplayField("jenis_kontrak");  
	cboJnsKontrak.setWidth(100);  
	cboJnsKontrak.setStore(storeJnsKontrak);  
	cboJnsKontrak.setTypeAhead(true);  
	cboJnsKontrak.setTriggerAction(TriggerAction.ALL);

fieldSet.add(cboJnsKontrak, formData);


		MultiField tglPjbb = new MultiField();
		tglPjbb.setFieldLabel("M Berlaku PJBB");
		tglPjbb.setSpacing(15);
		
		final DateField tglPjbbD = new DateField();
		tglPjbbD.setWidth(120);
		tglPjbbD.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
		tglPjbb.add(tglPjbbD);
		
	    LabelField lcvterima = new LabelField("S/D");
	    lcvterima.setWidth(20);
	    tglPjbb.add(lcvterima);
		
		final DateField tglBlakuD = new DateField();
		tglBlakuD.setWidth(140);
		tglBlakuD.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));		
		tglPjbb.add(tglBlakuD);
				
		fieldSet.add(tglPjbb, formData);
//		
		
		MultiField mVol = new MultiField();
		mVol.setFieldLabel("Vol PJBB");
		mVol.setSpacing(15);

				
		final NumberField  volPjbb = new NumberField();
		volPjbb.setWidth(120);
		volPjbb.setValidateOnBlur(true);		
		mVol.add(volPjbb);
		
	    LabelField lTahun = new LabelField("Vol THN");
	    lTahun.setWidth(50);
	    mVol.add(lTahun);
		
	    final NumberField  volPjbbThn = new NumberField();
	    volPjbbThn.setWidth(120);
	    volPjbbThn.setValidateOnBlur(true);	    
	    mVol.add(volPjbbThn);
	    
	    fieldSet.add(mVol, formData);
	    
	    
	    
		MultiField mHrgTon = new MultiField();
		mHrgTon.setFieldLabel("HRG / Ton");
		mHrgTon.setSpacing(15);

				
		final NumberField  hrgTon = new NumberField();
		hrgTon.setWidth(100);
		hrgTon.setValidateOnBlur(true);		
		mHrgTon.add(hrgTon);
		
	    LabelField lhrgPenys = new LabelField("Hrg Psesuai");
	    lhrgPenys.setWidth(80);
	    mHrgTon.add(lhrgPenys);
		
	    final NumberField  hrgPenys = new NumberField();
	    hrgPenys.setWidth(100);
	    hrgPenys.setValidateOnBlur(true);	    
	    mHrgTon.add(hrgPenys);
	    
	    fieldSet.add(mHrgTon, formData);

	    MultiField mNilaiKontrak = new MultiField();
	    mNilaiKontrak.setFieldLabel("Nilai Kontrak");
	    mNilaiKontrak.setSpacing(15);
//	    mNilaiKontrak.setVisible(false);
				
		final NumberField  nilaiKontrak = new NumberField();
		nilaiKontrak.setWidth(120);
		nilaiKontrak.setValidateOnBlur(true);		
		mNilaiKontrak.add(nilaiKontrak);
		
	    LabelField lKalori = new LabelField("Kalori");
	    lKalori.setWidth(40);
	    mNilaiKontrak.add(lKalori);
		
	    final NumberField  kalori = new NumberField();
	    kalori.setWidth(120);
	    kalori.setValidateOnBlur(true);	    
	    mNilaiKontrak.add(kalori);	    
	    fieldSet.add(mNilaiKontrak, formData);
	    
	    
		MultiField mKbthPerTahun = new MultiField();
		mKbthPerTahun.setFieldLabel("Kebutuhan / THN");
		mKbthPerTahun.setSpacing(15);

				
		final NumberField  kbthPerTahun = new NumberField();
		kbthPerTahun.setWidth(120);
		kbthPerTahun.setValidateOnBlur(true);		
		mKbthPerTahun.add(kbthPerTahun);
		
	    LabelField llot = new LabelField("LOT");
	    llot.setWidth(50);
	    mKbthPerTahun.add(llot);
		
	    final NumberField  lot = new NumberField();
	    lot.setWidth(120);
	    lot.setValidateOnBlur(true);	    
	    mKbthPerTahun.add(lot);
	    
	    fieldSet.add(mKbthPerTahun, formData);

	    
//	    final TextField<String> lot = new TextField<String>();	    
//	    lot.setName("lot"); 
//	    lot.setValidateOnBlur(true);
//	    lot.setFieldLabel("LOT");    
//	    fieldSet.add(lot, formData);

	    
	    final TextField<String> jnsTrans = new TextField<String>();	    
	    jnsTrans.setName("jenis_pengiriman"); 
	    jnsTrans.setValidateOnBlur(true);
	    jnsTrans.setFieldLabel("JNS kapal");    
	    fieldSet.add(jnsTrans, formData);
   
	
	final TextArea jaminanBank = new TextArea();  
	jaminanBank.setName("jaminan_bank");
	jaminanBank.setValidateOnBlur(true);
	jaminanBank.setFieldLabel("Jaminan Bank");    
    fieldSet.add(jaminanBank, formData);	  	  

    final TextField<String> ket = new TextField<String>();  
    ket.setName("keterangan");
//    ket.setVisible(false);
    ket.setFieldLabel("keterangan");  
    
    fieldSet.add(ket, formData);	  	  
   
     panel.add(fieldSet);

    ContentPanel p = new ContentPanel();
    p.setHeaderVisible(false);	    
    p.setButtonAlign(HorizontalAlignment.RIGHT);  
    p.addButton(new Button("Reset", new SelectionListener<ButtonEvent>() {  
      @Override  
      public void componentSelected(ButtonEvent ce) {  
//        grid.getStore().rejectChanges();  
      }  
    }));  
    bSubmit = new Button("Submit");
    p.addButton(bSubmit);
    
//    p.addButton(bSubmit, new SelectionListener<ButtonEvent>() {
//    bSubmit.addSelectionListener(new SelectionListener<ButtonEvent>() {
//      @Override  
//      public void componentSelected(ButtonEvent ce) {  
//
//    	  MessageBox.confirm("Info", "Apakah Anda Yakin Ingin Menyimpan Data?",new Listener<MessageBoxEvent>() {
//
//			@Override
//			public void handleEvent(MessageBoxEvent be) {
//				// TODO Auto-generated method stub
//				Button btn = be.getButtonClicked();
//				if (btn.getText().equals("Yes")){
//				
//		    	  	Map mapParam = new FastMap();
//		    	  	mapParam.put("no_pjbb", noPjbb.getValue());
//		    	  	mapParam.put("id_pemasok", cboPemasok.getValue().get("id_pemasok").toString());
//		    	  	mapParam.put("id_jenis_kontrak", cboJnsKontrak.getValue().get("id_jenis_kontrak").toString());
//		    	  	mapParam.put("awal_berlaku", tglPjbbD.getRawValue());
//		    		mapParam.put("akhir_berlaku", tglBlakuD.getRawValue());	    		
//		    		mapParam.put("vol_pjbb", volPjbb.getValue().toString());
//		    		mapParam.put("vol_pjbb_thn", volPjbbThn.getValue().toString());
//		    		mapParam.put("hrg_ton", hrgTon.getValue().toString());		    		
//		    		mapParam.put("hrg_sesuai", hrgPenys.getValue().toString());
//		    		mapParam.put("nilai_kontrak", nilaiKontrak.getRawValue().toString());
//		    		mapParam.put("kalori", kalori.getValue().toString());
//		    		mapParam.put("kebutuhan_tahun", kbthPerTahun.getValue().toString());
//		    		mapParam.put("lot", lot.getValue().toString());
//		    		mapParam.put("jenis_kapal", jnsTrans.getValue().toString());
//		    		mapParam.put("jaminan_bank", jaminanBank.getValue());
//		    		mapParam.put("ket", ket.getValue());
//		    	    mapParam.put("id_pltu", Registry.get("id_pltu").toString());
//		    		mapParam.put("createby", Registry.get("whoAmI").toString());
//		    		mapParam.put("app_access", "WEB");
//		    		mapParam.put("crud", "CREATE");
//		    		
//		    		Set set = mapParam.entrySet(); 
//		    		Iterator i = set.iterator(); 
//		    		// Display elements 
//		    		while(i.hasNext()) { 
//		    		Map.Entry me = (Map.Entry)i.next(); 
//			    		GWT.log(me.getKey() + ": " + me.getValue()); 
//		    		} 
//		    			
//		    		rkapService.crudPengadaan("PJBB", mapParam,new AsyncCallback<List<Map>>() {
//		    			public void onFailure(Throwable caught) {
//		    				GWT.log(caught.getMessage(), null);
//		    			}
//
//		    			public void onSuccess(List<Map> result) {	    				
//		    				Info.display("debug ","notification code " + result );
////		    				noAntri.setVisible(true);	    				
//		    				gridKontrak.mask("load Data ....","x-mask-loading");
//		    				gridPltu.mask("load Data ....","x-mask-loading");
//		            		getServiceInfo("master_kontrak","KONTRAKBYKIT");
//		            		getServiceInfo("master_pltu","PEMBANGKITBYKONTRAK");
//		    				
//		    				MessageBox.alert("Informasi", " " + result, null);
//		    			}
//		    		});
//				}		
	    		//--
//			}
//		});
//      }  
//    });  

    panel.add(p);
    
    return panel;  
  }  
}
